PANTHEON™ manual

 Categories
 PANTHEON Help - Welcome
[Collapse]PANTHEON
 [Collapse]Guides for PANTHEON
  [Collapse]Guide for PANTHEON
   [Collapse]Settings
    [Expand]Subjects
    [Expand]Items
    [Expand]POS
    [Expand]Manufacturing
    [Expand]Personnel
     Calendar
    [Expand]Financials
    [Expand]Customs
    [Collapse]Program
     [Expand]Document Types
     [Collapse]Reports in PANTHEON
       Settings in Administration Panel
      [Expand]Reports Register
       Print Preview
      [Expand]Report Designer
      [Expand]Creating Reports
      [Expand]Groups and Aggregates
      [Expand]Formatting and Highlighting
       Nested Reports (Subreports)
      [Expand]Specifics of Printouts in PANTHEON
      [Collapse]Script
        "Hello, World!" Script
        Using Variables, Database Fields, and Aggregate Functions
        Using Report Objects in the Script
        Events
        Example of Using the "OnBeforePrint" Event
        Printing a Group Sum in the Group Header
        Running Total
        "OnAfterData" Event
        Service Objects
        Using the "Engine" Object
       [Expand]PANTHEON Functions for FastReport
       [Expand]Examples with Tables and Queries
       Report Design Considerations
      Document Texts
      Delivery Methods
     [Expand]Loyalty Cards
     [Expand]Administration Panel
     [Expand]Dashboard Components
      Dashboard Reports
      Ad-hoc analysis
     [Expand]ARES
      SQL urejevalnik
    [Expand]Documentation
    [Expand]Change User
   [Expand]Orders
   [Expand]Goods
   [Expand]Manufacturing
   [Expand]POS
   [Expand]Service
   [Expand]Financials
   [Expand]Personnel
   [Expand]Analytics
   [Expand]Desktop
   [Expand]Help
   [Expand]Messages and Warnings
   [Expand]Additional programs
   [Expand]Old products
  [Expand]Guide for PANTHEON Retail
  [Expand]Guide for PANTHEON Vet
  [Expand]Guide for PANTHEON Farming
 [Expand]User Manuals for PANTHEON
[Expand]PANTHEON Web
[Expand]PANTHEON Granules
[Expand]User Site

Load Time: 765.6392 ms
print   |
Label

Example of Using the "OnBeforePrint" Event

Example of Using the "OnBeforePrint" Event

To demonstrate this event create a report representing a list of clients. This report will include only those companies whose name begins with the letter "A".

Let's create a new project, place "TfrxDlDBTable" component on the form and set these properties:

UserName = 'Subjects'

Open the report designer and create a report like this:

Select the data band and switch to the “Events” tab in the object inspector:

To create an “OnBeforePrint” event handler (which is the most appropriate for us) double-click on the blank field to the right of the event’s name:

This adds a blank handler to the script and the designer switches to the “Code” tab.

All that is needed now is to type the following code in the handler’s body:

if  Copy(<Subjects."acSubject">, 1, 1) = 'A' then

  MasterData1.Visible := True

else

  MasterData1.Visible := False;

Run the report and make sure that the script works correctly:

Let's explain several things. One handler can be assigned to the events of more than one object - the “Sender” parameter shows which object has initiated the event. To assign an existing handler to an event, either type it directly into the object inspector, or select it from the drop-down list:

A link to a handler can be easily deleted - select the assigned handler in the object inspector and press the “Delete” key.

000001.gif

If event handler is deleted code still remains on the report but it is not used. It only event handler remains also no code is executed and no error occurs.

 



Rate this topic
Was this topic usefull?
Comments
Comment will also bo visible in forum!